package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.service.db1.CoreAlgorithmService;
import com.sailfish.springbootdemo.service.db1.TimerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/timer")
public class TimerController {

    @Autowired
    private CoreAlgorithmService coreAlgorithmService;

    @GetMapping("/judgeRefreshDeviceUpkeepStatus")
    public String judgeRefreshDeviceUpkeepStatus() {
        coreAlgorithmService.refreshDeviceUpkeepStatus(null);
        return "[judgeRefreshDeviceUpkeepStatusByAssetNumber] Timer Task performed on: " + new Date();
    }

    @GetMapping("/refreshValidityCertificationStatus")
    public String refreshValidityCertificationStatus() {
        coreAlgorithmService.refreshDeviceTechCapacityOverdueValidity();
        coreAlgorithmService.refreshSpecialTechCapacityOverdueValidity();
        coreAlgorithmService.refreshLineTechCapacityOverdueValidity();
        return "[refreshValidityCertificationStatus] Timer Task performed on: " + new Date();
    }
}
